package p270jp.pxv.android.newWorks.presentation.job;

import android.app.job.JobParameters;
import android.app.job.JobService;
import android.content.ComponentCallbacks;
import java.util.Objects;
import p013ad.Action;
import p013ad.Consumer;
import p014ae.C0146r;
import p014ae.C0147r4;
import p041ba.C1048a;
import p044bd.DisposableHelper;
import p047bg.C1124a;
import p064c6.Preconditions;
import p071cd.Functions;
import p089d.C2424f;
import p134ei.PixivAnalytics;
import p136ek.NewWorksNotificationProperties;
import p161fk.NewWorksNotificationCheckService;
import p189gn.AbstractC3435a;
import p189gn.AbstractC3446l;
import p206hd.MaybeCallbackObserver;
import p206hd.MaybeFilterSingle;
import p206hd.MaybeMap;
import p206hd.MaybeObserveOn;
import p206hd.MaybePeek;
import p206hd.MaybeSubscribeOn;
import p206hd.RunnableC3600h;
import p210hh.PixivAccountManager;
import p213hk.NotificationUtils;
import p216hn.Lambda;
import p216hn.Reflection;
import p239ik.PushNotificationReceivedEvent;
import p325m0.MutabilityOwnership;
import p350mp.Timber;
import p436q6.StringMerger;
import p467rd.subscribers;
import p491sd.C6034a;
import p579vo.Qualifier;
import p593wc.AbstractC6904o;
import p603wm.AbstractC6949c;
import p603wm.Unit;
import p645yc.AndroidSchedulers;
import p665z6.C7470y;
import p671zc.Disposable;

/* compiled from: FollowUserNewWorksNotificationJob.kt */
/* renamed from: jp.pxv.android.newWorks.presentation.job.FollowUserNewWorksNotificationJob */
/* loaded from: classes2.dex */
public final class FollowUserNewWorksNotificationJob extends JobService {

    /* renamed from: a */
    public Disposable f19148a = C2424f.m7739s();

    /* renamed from: b */
    public final AbstractC6949c f19149b = Preconditions.m9802P(1, new C4272d(this, null, null));

    /* renamed from: c */
    public final AbstractC6949c f19150c = Preconditions.m9802P(1, new C4273e(this, null, null));

    /* renamed from: d */
    public final AbstractC6949c f19151d = Preconditions.m9802P(1, new C4274f(this, null, null));

    /* compiled from: FollowUserNewWorksNotificationJob.kt */
    /* renamed from: jp.pxv.android.newWorks.presentation.job.FollowUserNewWorksNotificationJob$a */
    /* loaded from: classes2.dex */
    public static final class C4269a extends Lambda implements AbstractC3446l<Throwable, Unit> {

        /* renamed from: b */
        public final /* synthetic */ JobParameters f19153b;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4269a(JobParameters jobParameters) {
            super(1);
            this.f19153b = jobParameters;
        }

        @Override // p189gn.AbstractC3446l
        public Unit invoke(Throwable th) {
            Throwable th2 = th;
            MutabilityOwnership.m3745m(th2, "it");
            Timber.f23100a.mo3527b(th2);
            FollowUserNewWorksNotificationJob.this.jobFinished(this.f19153b, false);
            return Unit.f29503a;
        }
    }

    /* compiled from: FollowUserNewWorksNotificationJob.kt */
    /* renamed from: jp.pxv.android.newWorks.presentation.job.FollowUserNewWorksNotificationJob$b */
    /* loaded from: classes2.dex */
    public static final class C4270b extends Lambda implements AbstractC3435a<Unit> {

        /* renamed from: b */
        public final /* synthetic */ JobParameters f19155b;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4270b(JobParameters jobParameters) {
            super(0);
            this.f19155b = jobParameters;
        }

        @Override // p189gn.AbstractC3435a
        public Unit invoke() {
            FollowUserNewWorksNotificationJob.this.jobFinished(this.f19155b, false);
            return Unit.f29503a;
        }
    }

    /* compiled from: FollowUserNewWorksNotificationJob.kt */
    /* renamed from: jp.pxv.android.newWorks.presentation.job.FollowUserNewWorksNotificationJob$c */
    /* loaded from: classes2.dex */
    public static final class C4271c extends Lambda implements AbstractC3446l<NewWorksNotificationProperties, Unit> {

        /* renamed from: b */
        public final /* synthetic */ JobParameters f19157b;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4271c(JobParameters jobParameters) {
            super(1);
            this.f19157b = jobParameters;
        }

        @Override // p189gn.AbstractC3446l
        public Unit invoke(NewWorksNotificationProperties aVar) {
            NewWorksNotificationProperties aVar2 = aVar;
            ((NotificationUtils) FollowUserNewWorksNotificationJob.this.f19150c.getValue()).m5502a(FollowUserNewWorksNotificationJob.this, aVar2.f13842a, aVar2.f13843b, aVar2.f13844c, aVar2.f13845d);
            ((PixivAnalytics) FollowUserNewWorksNotificationJob.this.f19149b.getValue()).m6526d(new PushNotificationReceivedEvent(aVar2.f13845d, aVar2.f13842a, aVar2.f13843b, aVar2.f13844c));
            FollowUserNewWorksNotificationJob.this.jobFinished(this.f19157b, false);
            return Unit.f29503a;
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.newWorks.presentation.job.FollowUserNewWorksNotificationJob$d */
    /* loaded from: classes2.dex */
    public static final class C4272d extends Lambda implements AbstractC3435a<PixivAnalytics> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f19158a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4272d(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f19158a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [ei.e, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final PixivAnalytics invoke() {
            return C1124a.m10173s(this.f19158a).f24118a.m920a().m621a(Reflection.m5499a(PixivAnalytics.class), null, null);
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.newWorks.presentation.job.FollowUserNewWorksNotificationJob$e */
    /* loaded from: classes2.dex */
    public static final class C4273e extends Lambda implements AbstractC3435a<NotificationUtils> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f19159a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4273e(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f19159a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [hk.a, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final NotificationUtils invoke() {
            return C1124a.m10173s(this.f19159a).f24118a.m920a().m621a(Reflection.m5499a(NotificationUtils.class), null, null);
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.newWorks.presentation.job.FollowUserNewWorksNotificationJob$f */
    /* loaded from: classes2.dex */
    public static final class C4274f extends Lambda implements AbstractC3435a<NewWorksNotificationCheckService> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f19160a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4274f(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f19160a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [fk.b, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final NewWorksNotificationCheckService invoke() {
            return C1124a.m10173s(this.f19160a).f24118a.m920a().m621a(Reflection.m5499a(NewWorksNotificationCheckService.class), null, null);
        }
    }

    @Override // android.app.job.JobService
    public boolean onStartJob(JobParameters jobParameters) {
        MutabilityOwnership.m3745m(jobParameters, "job");
        Timber.f23100a.mo3528a("Called onStartJob", new Object[0]);
        if (!PixivAccountManager.m5511e().f16506l) {
            return false;
        }
        NewWorksNotificationCheckService bVar = (NewWorksNotificationCheckService) this.f19151d.getValue();
        MaybeFilterSingle cVar = new MaybeFilterSingle(bVar.m6290a(bVar.f14647a.m6295a(), bVar.f14647a.m6294b(), bVar.f14647a.f14646a.f15666a.f15665a.getString("new_from_following_last_notified_date", null)).m971e(new C0147r4(bVar, 9)), C7470y.f31341r);
        C0146r rVar = new C0146r(bVar, 10);
        Consumer<Object> eVar = Functions.f5387d;
        Action aVar = Functions.f5386c;
        MaybeMap dVar = new MaybeMap(new MaybePeek(cVar, eVar, rVar, eVar, aVar, aVar, aVar), new C1048a(bVar, 21));
        AbstractC6904o oVar = C6034a.f26178c;
        Objects.requireNonNull(oVar, "scheduler is null");
        AbstractC6904o a = AndroidSchedulers.m334a();
        C4269a aVar2 = new C4269a(jobParameters);
        C4270b bVar2 = new C4270b(jobParameters);
        C4271c cVar2 = new C4271c(jobParameters);
        AbstractC3446l<Object, Unit> lVar = subscribers.f25774a;
        Consumer a2 = subscribers.m2595a(cVar2);
        Consumer<Throwable> c = subscribers.m2593c(aVar2);
        Action b = subscribers.m2594b(bVar2);
        Objects.requireNonNull(a2, "onSuccess is null");
        Objects.requireNonNull(c, "onError is null");
        Objects.requireNonNull(b, "onComplete is null");
        MaybeCallbackObserver bVar3 = new MaybeCallbackObserver(a2, c, b);
        Objects.requireNonNull(bVar3, "observer is null");
        try {
            MaybeObserveOn eVar2 = new MaybeObserveOn(bVar3, a);
            Objects.requireNonNull(eVar2, "observer is null");
            try {
                MaybeSubscribeOn gVar = new MaybeSubscribeOn(eVar2);
                eVar2.mo996c(gVar);
                DisposableHelper.m10366d(gVar.f16450a, oVar.mo978b(new RunnableC3600h(gVar, dVar)));
                this.f19148a = bVar3;
                return true;
            } catch (NullPointerException e) {
                throw e;
            } catch (Throwable th) {
                StringMerger.m2841u(th);
                NullPointerException nullPointerException = new NullPointerException("subscribeActual failed");
                nullPointerException.initCause(th);
                throw nullPointerException;
            }
        } catch (NullPointerException e2) {
            throw e2;
        } catch (Throwable th2) {
            StringMerger.m2841u(th2);
            NullPointerException nullPointerException2 = new NullPointerException("subscribeActual failed");
            nullPointerException2.initCause(th2);
            throw nullPointerException2;
        }
    }

    @Override // android.app.job.JobService
    public boolean onStopJob(JobParameters jobParameters) {
        MutabilityOwnership.m3745m(jobParameters, "job");
        this.f19148a.mo78a();
        return false;
    }
}
